package org.freelan.apps;

import android.app.*;
import android.content.*;
import android.os.*;
import android.view.*;
import android.widget.*;
import java.util.*;
import android.widget.AdapterView.*;

public class MainActivity extends Activity
{

    private ListView listaprincipal;

    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState)
	{
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
		
		listaprincipal=(ListView)findViewById(R.id.listaprincipallayout);
		
		String [] menu=getResources().getStringArray(R.array.menugaston);
		String [] submenu=getResources().getStringArray(R.array.submenugaston);
		
		List<Map<String, String>> datalist=new ArrayList<Map<String, String>>();
		
		for(int i=0; i< menu.length; i++){
			Map<String, String> data=new HashMap<String, String>();
			data.put("titulo", menu[i]); 
			data.put("comentario", submenu[i]);
			datalist.add(data);
		}
		
		SimpleAdapter adapter=new SimpleAdapter(this, datalist, 
		android.R.layout.simple_list_item_2,
		new String[] { "titulo", "comentario"},
		new int[]{ android.R.id.text1, android.R.id.text2});
		
		listaprincipal.setAdapter(adapter);
		listaprincipal.setOnItemClickListener(new OnItemClickListener(){
			public void onItemClick(AdapterView<?> l, View v, int pos, long arg){
				
				switch (pos)
				{
					case 0:
						registroIngreso(v);
						break;
					case 1:
						registroCargo(v);
						break;
		
	}

			}
		});
	
	
	 }
	 
	 public void registroIngreso(View v){
		 Intent i=new Intent(MainActivity.this, RegistroIngreso.class);
		 startActivity(i);
	 }
	 
	 public void registroCargo(View v){
		 Intent i=new Intent(MainActivity.this, RegistroCargos.class);
		 startActivity(i);
	 }


}
